package week04;

import java.util.Arrays;
import java.util.Scanner;

abstract class Shape{
	final static double  PI=3.14;
	public abstract double getPerimeter();
	public abstract double getArea();
    public abstract String toString();
}
class Circle extends Shape{
	private int radius;
	
	public Circle(int radius) {
		this.radius = radius;
	}
	public double getPerimeter() {
		return 2*Shape.PI*radius;
	}
	public double getArea() {
		return Shape.PI*radius*radius;
	}
	@Override
	public String toString() {
		return "Circle [radius=" + radius + "]";
	}
	
}
class Rectangle extends Shape{
	private int width,length;
	
	
	public Rectangle(int width, int length) {
		this.width = width;
		this.length = length;
	}
	public double getPerimeter() {
		return 2*(length+width);
	}
	public double getArea() {
		return length*width;
	}
	@Override
	public String toString() {
		return "Rectangle [width=" + width + ", length=" + length + "]";
	}

	
}
public class PTAjicheng {
	public static double sumAllPerimeter(Shape []shapes) {
		double sum=0.0;
		for(int i=0;i<shapes.length;i++)
			sum+=shapes[i].getPerimeter();
		return sum;
	}
	public static double sumAllArea(Shape []shapes) {
		double sum=0.0;
		for(int i=0;i<shapes.length;i++)
			sum+=shapes[i].getArea();
		return sum;
	}

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner in = new Scanner(System.in);
		int n= Integer.parseInt(in.nextLine());
		Shape []shapes=new Shape[n];
		for(int i=0;i<shapes.length;i++) {
			String str=in.nextLine();
			if(str.equals("rect")) {
				String str1=in.nextLine();
				String []str2=str1.split(" ");
				Rectangle rect=new Rectangle(Integer.parseInt(str2[0]),Integer.parseInt(str2[1]));
				shapes[i]=rect;
			}
			else if(str.equals("cir")){
				String []str3=in.nextLine().split(" ");
				Circle cir=new Circle(Integer.parseInt(str3[0]));
				shapes[i]=cir;
			}
		}
		System.out.println(sumAllPerimeter(shapes));
		System.out.println(sumAllArea(shapes));
		System.out.println(Arrays.toString(shapes));
		for(int i=0;i<shapes.length;i++)
			System.out.println(shapes[i].getClass()+","+shapes[i].getClass().getSuperclass());
	}
}
